package vip.web3.common.utils;

/**
 * 正则
 *
 */
public class PatternUtils {

    /**
     * 校验是否是手机号码
     *
     * @param content
     * @return true 是 false 不是
     */
    public static boolean pureMobile(String content) {
        String regex = "^1(3|4|5|6|7|8|9)\\d{9}$";
        return content.matches(regex);
    }

    /**
     * 校验是否ETH地址
     *
     * @param content
     * @return true 纯数字
     */
    public static boolean pureETHAddress(String content) {
        String regex = "^0x[0-9a-fA-F]{40}$";
        return content.matches(regex);
    }


    /**
     * 校验是否是纯数字
     *
     * @param content
     * @return true 纯数字
     */
    public static boolean pureNumbers(String content) {
        String regex = "^[0-9]*$";
        return content.matches(regex);
    }

    /**
     * 校验是否邮箱
     *
     * @param content
     * @return true
     */
    public static boolean pureEMail(String content) {
        String regex = "^\\s*\\w+(?:\\.{0,1}[\\w-]+)*@[a-zA-Z0-9]+(?:[-.][a-zA-Z0-9]+)*\\.[a-zA-Z]+\\s*$"  ;
        return content.matches(regex);
    }

    /**
     * 密码规则
     *
     * @param content
     * @return true
     */
    public static boolean matchPassword(String content) {
        String regex = "^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{6,16}$"  ;
        return content.matches(regex);
    }

    /**
     * 校验身份证
     *
     * @param content
     * @return true
     */
    public static boolean matchId(String content) {
        String regex = "^[1-9]\\d{5}(18|19|([23]\\d))\\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\\d{3}[0-9Xx]$";
        return content.matches(regex);
    }

}
